Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent reimports for TF #1713

Merged
merged 1 commit into from
Jun 16, 2020
Merged

Prevent reimports for TF #1713

merged 1 commit into from
Jun 16, 2020

Conversation

zhiltsov-max
Copy link
Contributor

Motivation and context

  • Updated TF import check so that TF couldn't be re-imported with default import expression if an import error happens

How has this been tested?

Manual test

Checklist

License

  • I submit my code changes under the same MIT License that covers the project.
    Feel free to contact the maintainers if that's a concern.
  • I have updated the license header for each file (see an example below)
# Copyright (C) 2020 Intel Corporation
#
# SPDX-License-Identifier: MIT

Copy link
Contributor

Codacy Here is an overview of what got changed by this pull request:

Complexity increasing per file
==============================
- datumaro/datumaro/util/tf_util.py  2
         

See the complete overview on Codacy

@coveralls
Copy link

Pull Request Test Coverage Report for Build 5760

  • 6 of 10 (60.0%) changed or added relevant lines in 1 file are covered.
  • 7 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.04%) to 65.756%

Changes Missing Coverage Covered Lines Changed/Added Lines %
datumaro/datumaro/util/tf_util.py 6 10 60.0%
Files with Coverage Reduction New Missed Lines %
cvat/apps/engine/media_extractors.py 7 75.59%
Totals Coverage Status
Change from base Build 5743: -0.04%
Covered Lines: 10920
Relevant Lines: 16214

💛 - Coveralls

@@ -35,16 +35,23 @@ def check_import():
def import_tf(check=True):
import sys

tf = sys.modules.get('tensorflow', None)
if tf is not None:
not_found = object()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it performance optimisation? Could you please add a comment?

Copy link
Contributor Author

@zhiltsov-max zhiltsov-max Jun 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not entirely. It is a way to be sure about the result of get() call. The problem with default None is that it is a valid value for a module, and, moreover, we need it later. Using some specific object() we can be sure about existence of a key and its value.

Copy link
Contributor

@nmanovic nmanovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nmanovic nmanovic merged commit 1385dc4 into develop Jun 16, 2020
@bsekachev bsekachev deleted the zm/enhance-tf-check branch June 17, 2020 15:42
frndmg pushed a commit to signatrix/cvat that referenced this pull request Aug 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants